<?php 
  header('Content-type: text/xml; charset=UTF-8');
  print '<?'  ?>xml version="1.0" encoding="UTF-8"?>
<?php 

  require_once('db.php');
  require_once('friends.php');
  
  if (!isset($_GET['nick'])) die('no nick');
  $nick = str_replace('\'', '', $_GET['nick']);
  $nick = addslashes(strip_tags($nick));
  
  $stats = stats($nick);

?>
<rss version="2.0">

  <channel>

    <title><?= $nick ?> cibas draudzības</title>
    <description>draudzības, jā, draudzības</description>
    <link>http://cu.serveris.lv</link>
    
    <?php foreach ($stats as $ev): ?>
    <item>
      <guid isPermaLink="false"><?= $ev['action'].'-'.$ev['time'].'-'.$ev['nick']?></guid>
      <?php if ($ev['action'] == 'start'): ?>
        <title>Jauna draudzība: <?= $ev['nick'] ?></title>
        <description>
          <?= strftime('%d.%m.%Y %H:%M:%S', $ev['time']) ?> es konstatēju, ka &lt;strong&gt;<?= $ev['nick'] ?>&lt;/strong&gt;
          uzsāk draudzību ar tevi!  
        </description>
      <?php endif; ?>
      <?php if ($ev['action'] == 'finish'): ?>
        <title>Pārtraukta draudzība: <?= $ev['nick'] ?></title>
        <description>
          <?= strftime('%d.%m.%Y %H:%M:%S', $ev['time']) ?> es konstatēju, ka &lt;strong&gt;<?= $ev['nick'] ?>&lt;/strong&gt;
          pārtrauc draudzību ar tevi :(
        </description>
      <?php endif; ?>    
    </item>
    <?php endforeach; ?>
  </channel>

</rss>
